package cn.linran.fallback;

import cn.linran.domain.User;
import cn.linran.enums.GlobalErrorCode;
import cn.linran.feign.UserFeignClient;
import cn.linran.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author Lin
 * @ClassName UserFeignClientFallbackFactory.java
 * @Description:
 * @createTime 2022年08月29日 10:34
 */
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            /**
             * movie保存/更新用户信息
             * @param user
             * @return
             */
            @Override
            public JSONResult saveOrUpdate(User user) {
                return JSONResult.error(GlobalErrorCode.SERVICE_ERROR);
            }

            /**
             * 根据用户id查询的熔断方法
             * @param id
             * @return
             */
            @Override
            public JSONResult get(Long id) {
                return JSONResult.error(GlobalErrorCode.SERVICE_ERROR);
            }
        };
    }
}
//@RestController
//@RequestMapping("/user")
//public class UserController {
//    @Autowired
//    private UserFeignClient movieFeignClient;
//
//    /**
//     * 调用feign接口查询所有的票
//     */
//    @RequestMapping(value = "/list",method = RequestMethod.GET)
//    public JSONResult list(){
//        return movieFeignClient.list();
//    }
//}